<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>   
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>用户信息-增加</title>
		<link type="text/css" rel="stylesheet" href="<%=basePath%><s:property value="#session.themeStyle.mainCss" default="Skin/PM/LightBlue/main.css"/>" />
		<script src="<%=basePath %>js/jquery.js" type="text/javascript"></script>
		<script src="<%=basePath %>js/store.js" type="text/javascript"></script>
		<script type="text/javascript">
			function saveUser() {
				var userName = $.trim($("#userName").val());
				if(userName==""){
					alert("用户账号不能为空！");
					return false;
				}
				//判断用户账号是否被注册
				$.post("checkUserCode.action", {userName:userName},
					function(data){
				    	if(data=="1"){
				    		//验证可用
				    		addUser();
				    	}else{
				    		//验证不可用，账号已经被注册！
				    		alert("账号已存在！");
				    		return false;
				    	}
				});
				
				
			}
			function addUser(){
				var userName = $.trim($("#userName").val());
				var name = $.trim($("#name").val());
				if(name == ""){
					alert("用户姓名不能为空！");
					return false;
				}
				var password = $.trim($("#password").val());
				if(password==""){
					alert("密码不能为空！");
					return false;
				}
				var telphone = $.trim($("#telphone").val());
				var email = $.trim($("#email").val());
				var address = $.trim($("#address").val());
				
				window.returnValue="[{\"userName\":'"+userName+"',\"name\":'"+name+"',\"password\":'"+password+"',\"telphone\":'"+telphone+"',\"email\":'"+email+"',\"address\":'"+address+"'}]";
    			window.close();
			}
		</script>
		<style type="text/css">
	
		 .toolbar a:hover{
		 		color: #ccc;
		 		font-size: 14px;
		 }
	</style>
	</head>
<body>
	<div style="margin-left: 8px;margin-right: 8px;border-bottom: 2px #3497cf solid;height: 24px;margin-top: 0px;line-height: 24px;">
			当前位置：系统管理&nbsp;&gt;&gt;&nbsp;用户管理 &nbsp;&gt;&gt;&nbsp;新增用户
	</div>
	<div class="tabBlock">
		<div class="editBlock">
				<table>
					  <tbody>
						  <tr>
						    <th style="color:#000000;">用户帐号</th>
						    <td ><input class="inputText" id="userName" name="userName" maxlength="40" type="text"  value="${userName}" />
						    </td>
						    <th style="color:#000000;">用户姓名</th>
						    <td ><input class="inputText" id="name" name="name" maxlength="40" type="text"  value="${name}" /></td>
						  </tr>
						  <tr>
						  	<th style="color:#000000;">密码</th>
						    <td ><input class="inputText" id="password" name="password" maxlength="20" type="text"  value="${password}" /></td>
						  	<th style="color:#000000;">电话</th>
						    <td ><input class="inputText" id="telphone" name="telphone" type="text" maxlength="20" value="${telphone}" /></td>
						  </tr>
						  <tr>
						  	<th style="color:#000000;">电子邮件</th>
						    <td ><input class="inputText" id="email" name="email" type="text" maxlength="200"  value="${email}" /></td>
						  	<th style="color:#000000;">通讯地址</th>
						    <td ><input class="inputText" id="address" name="address" type="text" maxlength="200" value="${address}" /></td>
						  </tr>
						<tr>
					    <th colspan="4" style="color:red;text-align:left;padding-left:10px;">${message}</th>
					   </tr>
					</tbody>
				</table>
			</div>
			<div class="toolbar" align="center" style="text-align: center;">
				<a class="but28" onclick="saveUser();" style="text-decoration:none;" >添加</a>
			</div>
		</div>
</body>
</html>